<?php

namespace yuankezhan\yiiTableWidget;

use yii\helpers\Html;

class GroupButton
{
    /**
     * @var TableButton[] $buttonArr
     */
    public $buttonArr = [];

    /**
     * @var string $groupName 按钮组名称
     */
    public $groupName;
    public static function set($groupName, $buttonArr)
    {
        return new static($groupName, $buttonArr);
    }

    public function __construct($groupName, $buttonArr)
    {
        $this->groupName = $groupName;
        $this->buttonArr = $buttonArr;
    }

    public function create()
    {
        $str = "<div class='public-table-btn-group' style='cursor: pointer'> 
                <div class='public-table-btn-group-name'>
                    <span>{$this->groupName}</span>
                    <svg t='1711508157937' class='public-table-icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1577' width='200' height='200'><path d='M54.4 348.8l428.8 416c9.6 6.4 19.2 9.6 28.8 9.6 9.6 0 22.4-3.2 28.8-9.6l428.8-416c16-12.8 16-35.2 0-48s-41.6-12.8-54.4 0L512 688 108.8 300.8c-12.8-16-38.4-16-54.4 0-16 12.8-16 35.2 0 48z' fill='' p-id='1578'></path></svg>
                </div>
                <div class='public-table-btn-group-content hidden'><div class='public-table-btn-group-content-box'>";
        foreach ($this->buttonArr as $button)
        {
            $str .= $button->create();
        }
        return $str . "</div></div></div>";
    }


}